﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Test.ExpressionVisitors
{
	internal class ParameterExpressionRewriter : ExpressionVisitor
	{
		Dictionary<Type, string> name_map;
		public ParameterExpressionRewriter(Dictionary<Type, string> name_map) {
			this.name_map = name_map;
		}

		
		public override Expression Visit(Expression node) {
			//switch (node.NodeType) {
			//    case ExpressionType.Parameter:
					
			//        break;
			//}
			return base.Visit(node);
		}
		//todo: this should also search through MemberExpression instances
		protected override Expression VisitParameter(ParameterExpression node) {
			if (name_map.ContainsKey(node.Type)) {
				return Expression.Parameter(node.Type, this.name_map[node.Type]);
			}
			return base.VisitParameter(node);
		}
	}
}
